package com.hhs.storage.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.hhs.storage.util.SysUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author hhs
 * @since 2023-02-23
 */
@Data
public class BusinessDispatchOrder implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final int STATUS_CREATE=0;//待完成
    public static final int STATUS_COMPLETE=1;//已完成

    private String id;

    /**
     * 派单id
     */
    private String orderId;

    /**
     * 车辆id
     */
    private String carId;

    /**
     * 运输数量
     */
    private BigDecimal num;

    /**
     * 状态0未完成，1已完成，2取消
     */
    private Integer state;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 完成时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime completeTime;

    /**
     * 装货时间
     */
    @JSONField(format="HH:mm")
    @DateTimeFormat(pattern = "HH:mm")
    private LocalTime loadTime;

    /**
     * 卸货时间
     */
    @JSONField(format="HH:mm")
    @DateTimeFormat(pattern = "HH:mm")
    private LocalTime unloadTime;

    /**
     * 装货总重
     */
    private BigDecimal weightLoadTotal;

    /**
     * 装货吨数
     */
    private BigDecimal weightLoad;

    /**
     * 卸货总重
     */
    private BigDecimal weightUnloadTotal;

    /**
     * 卸货吨数
     */
    private BigDecimal weightUnload;

    /**
     * 运费
     */
    private BigDecimal freight;

    /**
     * 公里数
     */
    private BigDecimal mileage;

    /**
     * 核定油升
     */
    private BigDecimal fuelNum;

    /**
     * 司机工资
     */
    private BigDecimal driverWage;

    /**
     * 金额
     */
    private BigDecimal price;
    /**
     * 是否填写过磅单，填写过为1
     */
    private Integer satchelFlag;

    /**
     * 金额
     */
    private BigDecimal lossPermille;
    @TableField(exist = false)
    private BusinessOrder businessOrder;

    @TableField(exist = false)
    private Car car;


    @JSONField(format = "yyyy-MM-dd ")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate loadDate;
    @JSONField(format = "yyyy-MM-dd ")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate unloadDate;

    public String getStateName(){
        return SysUtil.BUSINESS_DISPATCH_ORDER_STATE_MAP.get(this.state);
    }

}
